<?php

namespace app\index\controller\my;

use app\index\model\UM as UM;
use app\index\service\NumberService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * Number 控制器
 * Class Number
 * @package app\index\controller\my;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\my\Number
 */
class Number
{
    // 请求参数
    private Request $request;

    // service
    private NumberService $service;

    public function __construct(Request $request, NumberService $numberService)
    {
        $this->request = $request;
        $this->service = $numberService;
    }

    /**
     * 底部导航栏-红点
     * @param UM|null $user
     * @return ApiResponse
     * @url /my/number/read
     */
    public function read(?UM $user): ApiResponse
    {

        return ApiResponse::success($this->service->numberOfMember($user));
    }
}
